﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Manage.aspx.cs" Inherits="WinnerCMS.WebUI.Admin.Category.Manage" %>

<!doctype html>
<html>
<head runat="server">
    <title>栏目管理</title>
    <meta charset="utf-8" />
    <meta http-equiv="Pragma" content="No-cach" />
    <%: Scripts.Render("~/Scripts/AdminBase") %>
    <%: Styles.Render("~/Content/Bootstrap/css") %>

    <script type="text/javascript">
        function formatUP(value, rowData, rowIndex) {
            return "<a href=\"javascript:OrderByMove('UP'," + value + ")\">↑</a>";
        }

        function OrderByMove(ordertype, id) {
            $.post("/api/Category/OrderByMove", { OrderType: ordertype, ID: id },
                function () {
                    alert("操作完成。");
                    $('#tg').treegrid('reload');
                }, "JSON");
        }

        function formatDWON(value, rowData, rowIndex) {
            return "<a href=\"javascript:OrderByMove('DOWN'," + value + ")\">↓</a>";
        }
        function formatContentPage(value, rowData, rowIndex) {
            if (value == "0") {
                return "动态";
            }
            else {
                return "生成静态";
            }
        }
        function formatCategoryPage(value, rowData, rowIndex) {
            if (value == "0") {
                return "动态";
            }
            else {
                return "生成静态";
            }
        }
        function formatOP(value, rowData, rowIndex) {
            return "<a href=\"Add.aspx?Action=Add&amp;ParentId=" + value + "\">添加栏目</a>	<a href=\"Add.aspx?Action=Edit&amp;ID=" + value + "\">修改设置</a>	<a href=\"javascript:DeleteClass(" + value + ")\">删除栏目</a>	<a href=\"javascript:ClearCategory(" + value + ")\">清空栏目</a>";
        }
        function DeleteClass(id) {
            $.post("/api/Category/Delete?id=" + id, {},
              function () {
                  alert("删除完成。");
                  $('#tg').treegrid('reload');
              }, "JSON");
        }
        function ClearCategory(id) {
            $.post("/api/Category/Clear?id=" + id, {},
              function () {
                  alert("清空完成。");
                  $('#tg').treegrid('reload');
              }, "JSON");
        }
    </script>
</head>
<body class="easyui-layout">
    <div region="north" border="false" style="border-bottom: 1px solid #ddd; background: #fafafa; padding-left: 4px; height: 50px; overflow: hidden;">
        <table id="NavigationPath">
            <tr>
                <td>管理导航：<a href="Manage.aspx">栏目管理</a> | <a href="Add.aspx">添加栏目</a> | <a href="Move.aspx">移动栏目</a> | <a href="Merge.aspx">合并栏目</a> | <a href="Attribute.aspx">批量设置</a> | <a href="Permission.aspx">权限设置</a>
                </td>
            </tr>
        </table>
    </div>
    <div region="center" border="false">
        <table id="tg" class="easyui-treegrid" style="width: 100%; height: auto" data-options="
				iconCls: 'icon-ok',
				rownumbers: true,
				animate: true,
				collapsible: true,
				fitColumns: true,
                fit:true,
                method: 'post',
				url: '/api/Category/TreeList',
				idField: 'id',
				treeField: 'text'
			">
            <thead>
                <tr>
                    <th data-options="field:'id',width:50">ID
                    </th>
                    <th data-options="field:'text',width:250">栏目名称
                    </th>
                    <th data-options="field:'CustomField1',width:60,formatter:formatUP,align:'center'">上移
                    </th>
                    <th data-options="field:'CustomField2',width:60,formatter:formatDWON,align:'center'">下移
                    </th>
                    <th data-options="field:'CustomField3',width:60,formatter:formatContentPage,align:'center'">内容页
                    </th>
                    <th data-options="field:'CustomField4',width:60,formatter:formatCategoryPage,align:'center'">栏目页
                    </th>
                    <th data-options="field:'CustomField5',width:200,formatter:formatOP,align:'center'">操作
                    </th>
                </tr>
            </thead>
        </table>
    </div>
</body>
</html>
